กรณีนั่งทับที่ต้องเป็นตำแหน่งจริงของเขา #251
All checks were successful
Build & Deploy on Dev / build (push) Successful in 59s
All checks were successful
Build & Deploy on Dev / build (push) Successful in 59s
This commit is contained in:
parent
a422651e03
commit
7686ec2eac
1 changed files with 21 additions and 4 deletions
|
|
@ -11,6 +11,7 @@ import { PosMasterHistory } from "../entities/PosMasterHistory";
|
||||||
import { Position } from "../entities/Position";
|
import { Position } from "../entities/Position";
|
||||||
import { ProfileEducation } from "../entities/ProfileEducation";
|
import { ProfileEducation } from "../entities/ProfileEducation";
|
||||||
import { RequestWithUser } from "../middlewares/user";
|
import { RequestWithUser } from "../middlewares/user";
|
||||||
|
import { Profile } from "../entities/Profile";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* function สำหรับดึงตำแหน่งที่รักษาการแทน
|
* function สำหรับดึงตำแหน่งที่รักษาการแทน
|
||||||
|
|
@ -85,6 +86,7 @@ export async function CreatePosMasterHistoryOfficer(
|
||||||
const repoHistory = transactionManager.getRepository(PosMasterHistory);
|
const repoHistory = transactionManager.getRepository(PosMasterHistory);
|
||||||
const repoOrgRevision = transactionManager.getRepository(OrgRevision);
|
const repoOrgRevision = transactionManager.getRepository(OrgRevision);
|
||||||
const repoPosition = transactionManager.getRepository(Position);
|
const repoPosition = transactionManager.getRepository(Position);
|
||||||
|
const repoProfile = transactionManager.getRepository(Profile);
|
||||||
|
|
||||||
const pm = await repoPosmaster.findOne({
|
const pm = await repoPosmaster.findOne({
|
||||||
where: { id: posMasterId },
|
where: { id: posMasterId },
|
||||||
|
|
@ -132,6 +134,21 @@ export async function CreatePosMasterHistoryOfficer(
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let position = selectedPosition?.positionName ?? _null;
|
||||||
|
let posTypeName = selectedPosition?.posType?.posTypeName ?? _null;
|
||||||
|
let posLevelName = selectedPosition?.posLevel?.posLevelName ?? _null;
|
||||||
|
let posExecutiveName = selectedPosition?.posExecutive?.posExecutiveName ?? _null;
|
||||||
|
if (pm.isSit && pm.current_holderId) {
|
||||||
|
const profile = await repoProfile.findOne({
|
||||||
|
where: { id: pm.current_holderId },
|
||||||
|
relations: ["posType", "posLevel"]
|
||||||
|
});
|
||||||
|
position = profile?.position ?? _null;
|
||||||
|
posTypeName = profile?.posType?.posTypeName ?? _null;
|
||||||
|
posLevelName = profile?.posLevel?.posLevelName ?? _null;
|
||||||
|
posExecutiveName = profile?.posExecutive ?? _null;
|
||||||
|
}
|
||||||
|
|
||||||
h.ancestorDNA = pm.ancestorDNA ? pm.ancestorDNA : _null;
|
h.ancestorDNA = pm.ancestorDNA ? pm.ancestorDNA : _null;
|
||||||
if (!type || type != "DELETE") {
|
if (!type || type != "DELETE") {
|
||||||
if (checkCurrentRevision) {
|
if (checkCurrentRevision) {
|
||||||
|
|
@ -144,9 +161,9 @@ export async function CreatePosMasterHistoryOfficer(
|
||||||
h.firstName = pm.next_holder?.firstName || _null;
|
h.firstName = pm.next_holder?.firstName || _null;
|
||||||
h.lastName = pm.next_holder?.lastName || _null;
|
h.lastName = pm.next_holder?.lastName || _null;
|
||||||
}
|
}
|
||||||
h.position = selectedPosition?.positionName ?? _null;
|
h.position = position;
|
||||||
h.posType = selectedPosition?.posType?.posTypeName ?? _null;
|
h.posType = posTypeName;
|
||||||
h.posLevel = selectedPosition?.posLevel?.posLevelName ?? _null;
|
h.posLevel = posLevelName;
|
||||||
}
|
}
|
||||||
h.rootDnaId = pm.orgRoot?.ancestorDNA || _null;
|
h.rootDnaId = pm.orgRoot?.ancestorDNA || _null;
|
||||||
h.child1DnaId = pm.orgChild1?.ancestorDNA || _null;
|
h.child1DnaId = pm.orgChild1?.ancestorDNA || _null;
|
||||||
|
|
@ -156,7 +173,7 @@ export async function CreatePosMasterHistoryOfficer(
|
||||||
h.posMasterNoPrefix = pm.posMasterNoPrefix ?? _null;
|
h.posMasterNoPrefix = pm.posMasterNoPrefix ?? _null;
|
||||||
h.posMasterNo = pm.posMasterNo ?? _null;
|
h.posMasterNo = pm.posMasterNo ?? _null;
|
||||||
h.posMasterNoSuffix = pm.posMasterNoSuffix ?? _null;
|
h.posMasterNoSuffix = pm.posMasterNoSuffix ?? _null;
|
||||||
h.posExecutive = selectedPosition?.posExecutive?.posExecutiveName ?? _null;
|
h.posExecutive = posExecutiveName;
|
||||||
h.shortName =
|
h.shortName =
|
||||||
[
|
[
|
||||||
pm.orgChild4?.orgChild4ShortName,
|
pm.orgChild4?.orgChild4ShortName,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue