insert position to profile
All checks were successful
Build & Deploy on Dev / build (push) Successful in 1m8s

This commit is contained in:
Adisak 2026-04-20 16:01:38 +07:00
parent 28b5408d5b
commit f1c8ecf699
3 changed files with 35 additions and 28 deletions

View file

@ -3722,6 +3722,9 @@ export class CommandController extends Controller {
// ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ // ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ
if (positionNew != null) { if (positionNew != null) {
positionNew.positionIsSelected = true; positionNew.positionIsSelected = true;
// อัพเดท org และ posMasterNo ตลอดไม่ต้องดัก isSit
profile.posMasterNo = getPosMasterNo(posMaster);
profile.org = getOrgFullName(posMaster);
if(!posMaster.isSit){ if(!posMaster.isSit){
profile.posLevelId = positionNew.posLevelId; profile.posLevelId = positionNew.posLevelId;
profile.posTypeId = positionNew.posTypeId; profile.posTypeId = positionNew.posTypeId;
@ -3730,8 +3733,6 @@ export class CommandController extends Controller {
profile.posExecutive = positionNew.posExecutive?.posExecutiveName ?? null; profile.posExecutive = positionNew.posExecutive?.posExecutiveName ?? null;
profile.positionArea = positionNew.positionArea ?? null; profile.positionArea = positionNew.positionArea ?? null;
profile.positionExecutiveField = positionNew.positionExecutiveField ?? null; profile.positionExecutiveField = positionNew.positionExecutiveField ?? null;
profile.posMasterNo = getPosMasterNo(posMaster);
profile.org = getOrgFullName(posMaster);
} }
profile.amount = item.amount ?? null; profile.amount = item.amount ?? null;
profile.amountSpecial = item.amountSpecial ?? null; profile.amountSpecial = item.amountSpecial ?? null;
@ -6998,6 +6999,9 @@ export class CommandController extends Controller {
// ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ // ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ
if (positionNew != null) { if (positionNew != null) {
positionNew.positionIsSelected = true; positionNew.positionIsSelected = true;
// อัพเดท org และ posMasterNo ตลอดไม่ต้องดัก isSit
profile.posMasterNo = getPosMasterNo(posMaster);
profile.org = getOrgFullName(posMaster);
if(!posMaster.isSit){ if(!posMaster.isSit){
profile.posLevelId = positionNew.posLevelId; profile.posLevelId = positionNew.posLevelId;
profile.posTypeId = positionNew.posTypeId; profile.posTypeId = positionNew.posTypeId;
@ -7006,12 +7010,10 @@ export class CommandController extends Controller {
profile.posExecutive = positionNew.posExecutive?.posExecutiveName ?? null; profile.posExecutive = positionNew.posExecutive?.posExecutiveName ?? null;
profile.positionArea = positionNew.positionArea ?? null; profile.positionArea = positionNew.positionArea ?? null;
profile.positionExecutiveField = positionNew.positionExecutiveField ?? null; profile.positionExecutiveField = positionNew.positionExecutiveField ?? null;
profile.posMasterNo = getPosMasterNo(posMaster);
profile.org = getOrgFullName(posMaster);
// profile.dateStart = new Date(); // profile.dateStart = new Date();
}
await this.profileRepository.save(profile, { data: req }); await this.profileRepository.save(profile, { data: req });
setLogDataDiff(req, { before, after: profile }); setLogDataDiff(req, { before, after: profile });
}
await this.positionRepository.save(positionNew, { data: req }); await this.positionRepository.save(positionNew, { data: req });
} }
// await CreatePosMasterHistoryOfficer(posMaster.id, req); // await CreatePosMasterHistoryOfficer(posMaster.id, req);

View file

@ -3829,6 +3829,9 @@ export class PositionController extends Controller {
relations: ["posExecutive"], relations: ["posExecutive"],
}); });
if (_position) { if (_position) {
// อัพเดท org และ posMasterNo ตลอดไม่ต้องดัก isSit
_profile.posMasterNo = getPosMasterNo(dataMaster);
_profile.org = getOrgFullName(dataMaster);
// ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ // ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ
if(!dataMaster.isSit){ if(!dataMaster.isSit){
_profile.position = _position.positionName; _profile.position = _position.positionName;
@ -3838,13 +3841,11 @@ export class PositionController extends Controller {
_profile.posExecutive = _position.posExecutive?.posExecutiveName ?? undefined; _profile.posExecutive = _position.posExecutive?.posExecutiveName ?? undefined;
_profile.positionArea = _position.positionArea ?? undefined; _profile.positionArea = _position.positionArea ?? undefined;
_profile.positionExecutiveField = _position.positionExecutiveField ?? undefined; _profile.positionExecutiveField = _position.positionExecutiveField ?? undefined;
_profile.posMasterNo = getPosMasterNo(dataMaster); }
_profile.org = getOrgFullName(dataMaster);
await this.profileRepository.save(_profile); await this.profileRepository.save(_profile);
setLogDataDiff(request, { before, after: _profile }); setLogDataDiff(request, { before, after: _profile });
} }
} }
}
dataMaster.current_holderId = requestBody.profileId; dataMaster.current_holderId = requestBody.profileId;
dataMaster.next_holderId = _null; dataMaster.next_holderId = _null;
} else { } else {

View file

@ -652,12 +652,17 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
await posMasterAssignRepository.save(newAssigns); await posMasterAssignRepository.save(newAssigns);
} }
// ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ // อัพเดท org และ posMasterNo ตลอดไม่ต้องดัก isSit
if (item.next_holderId != null && !item.isSit) { if (item.next_holderId != null) {
const profile = await repoProfile.findOne({ const profile = await repoProfile.findOne({
where: { id: item.next_holderId == null ? "" : item.next_holderId }, where: { id: item.next_holderId == null ? "" : item.next_holderId },
}); });
if (profile != null && item.positions.length > 0) { if (profile != null) {
profile.posMasterNo = getPosMasterNo(item) ?? _null;
profile.org = getOrgFullName(item) ?? _null;
// ถ้าไม่ใช่ตำแหน่งนั่งทับ (isSit = false) ถึงจะอัพเดทตำแหน่งในทะเบียนประวัติ
if (!item.isSit && item.positions.length > 0) {
let position = await item.positions.find((x) => x.positionIsSelected == true); let position = await item.positions.find((x) => x.positionIsSelected == true);
if (position == null) { if (position == null) {
position = await item.positions.find((x) => x.posLevelId == profile?.posLevelId); position = await item.positions.find((x) => x.posLevelId == profile?.posLevelId);
@ -673,8 +678,7 @@ async function handler_org(msg: amqp.ConsumeMessage): Promise<boolean> {
profile.posExecutive = position?.posExecutive?.posExecutiveName ?? _null; profile.posExecutive = position?.posExecutive?.posExecutiveName ?? _null;
profile.positionArea = position?.positionArea ?? _null; profile.positionArea = position?.positionArea ?? _null;
profile.positionExecutiveField = position?.positionExecutiveField ?? _null; profile.positionExecutiveField = position?.positionExecutiveField ?? _null;
profile.posMasterNo = getPosMasterNo(item) ?? _null; }
profile.org = getOrgFullName(item) ?? _null;
await repoProfile.save(profile); await repoProfile.save(profile);
} }
} }