fix #2563
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m5s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m5s
This commit is contained in:
parent
51d447109e
commit
bdd31ce72c
2 changed files with 36 additions and 16 deletions
|
|
@ -39,8 +39,7 @@ import { RequestWithUser } from "../middlewares/user";
|
|||
import permission from "../interfaces/permission";
|
||||
import { setLogDataDiff } from "../interfaces/utils";
|
||||
import {
|
||||
CreatePosMasterHistoryEmployee,
|
||||
CreatePosMasterHistoryOfficer,
|
||||
CreatePosMasterHistoryEmployee
|
||||
} from "../services/PositionService";
|
||||
import { PosMasterEmployeeHistory } from "../entities/PosMasterEmployeeHistory";
|
||||
import { KeycloakAttributeService } from "../services/KeycloakAttributeService";
|
||||
|
|
@ -2377,26 +2376,47 @@ export class EmployeePositionController extends Controller {
|
|||
dataMaster.positions.forEach(async (position) => {
|
||||
if (position.id === requestBody.position) {
|
||||
position.positionIsSelected = true;
|
||||
const profile = await this.profileRepository.findOne({
|
||||
where: { id: requestBody.profileId },
|
||||
});
|
||||
if (profile != null) {
|
||||
const _null: any = null;
|
||||
profile.posLevelId = position?.posLevelId ?? _null;
|
||||
profile.posTypeId = position?.posTypeId ?? _null;
|
||||
profile.position = position?.positionName ?? _null;
|
||||
await this.profileRepository.save(profile);
|
||||
}
|
||||
} else {
|
||||
position.positionIsSelected = false;
|
||||
}
|
||||
await this.employeePositionRepository.save(position);
|
||||
});
|
||||
|
||||
const _null: any = null;
|
||||
const before = null;
|
||||
dataMaster.isSit = requestBody.isSit;
|
||||
dataMaster.current_holderId = requestBody.profileId;
|
||||
dataMaster.lastUpdatedAt = new Date();
|
||||
// dataMaster.next_holderId = requestBody.profileId;
|
||||
|
||||
//เช็คถ้า revision ปัจจุบันให้ปั๊มที่ profile
|
||||
const chkRevision = await this.orgRevisionRepository.findOne({
|
||||
where: { id: dataMaster.orgRevisionId },
|
||||
});
|
||||
if (chkRevision?.orgRevisionIsCurrent) {
|
||||
const _profile = await this.profileRepository.findOne({
|
||||
where: { id: requestBody.profileId },
|
||||
});
|
||||
if (_profile) {
|
||||
let _position = await this.employeePositionRepository.findOne({
|
||||
where: { id: requestBody.position, posMasterId: requestBody.posMaster },
|
||||
});
|
||||
if (_position) {
|
||||
|
||||
// ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ
|
||||
if (!dataMaster.isSit) {
|
||||
_profile.position = _position.positionName;
|
||||
_profile.posTypeId = _position.posTypeId;
|
||||
_profile.posLevelId = _position.posLevelId;
|
||||
}
|
||||
await this.profileRepository.save(_profile);
|
||||
setLogDataDiff(request, { before, after: _profile });
|
||||
}
|
||||
}
|
||||
dataMaster.current_holderId = requestBody.profileId;
|
||||
dataMaster.next_holderId = _null;
|
||||
} else {
|
||||
dataMaster.next_holderId = requestBody.profileId;
|
||||
dataMaster.current_holderId = _null;
|
||||
}
|
||||
|
||||
await this.employeePosMasterRepository.save(dataMaster);
|
||||
await CreatePosMasterHistoryEmployee(dataMaster.id, request);
|
||||
|
||||
|
|
|
|||
|
|
@ -1014,7 +1014,7 @@ export class UpdateInformationProfileEmployee {
|
|||
}
|
||||
|
||||
export type UpdateProfileEmployee = {
|
||||
prefix: string;
|
||||
prefix?: string | null;
|
||||
rank?: string | null;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue