update current

This commit is contained in:
mamoss 2025-08-18 22:56:04 +07:00
parent b0f5ff78d8
commit 8b7de2a0ba
6 changed files with 86 additions and 54 deletions

View file

@ -1431,13 +1431,7 @@ export class PositionController extends Controller {
@Get("position/{id}")
async detailPosition(@Path() id: string) {
const posMaster = await this.posMasterRepository.findOne({
relations: [
"orgRoot",
"orgChild1",
"orgChild2",
"orgChild3",
"orgChild4",
],
relations: ["orgRoot", "orgChild1", "orgChild2", "orgChild3", "orgChild4"],
where: { id },
});
if (!posMaster) {
@ -1474,7 +1468,7 @@ export class PositionController extends Controller {
posMaster.orgChild3Id == null
) {
shortName = posMaster.orgRoot.orgRootShortName;
orgId = posMaster.orgRootId;
orgId = posMaster.orgRootId;
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
@ -1482,7 +1476,7 @@ export class PositionController extends Controller {
posMaster.orgChild3Id == null
) {
shortName = posMaster.orgChild1.orgChild1ShortName;
orgId = posMaster.orgChild1Id;
orgId = posMaster.orgChild1Id;
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
@ -1490,7 +1484,7 @@ export class PositionController extends Controller {
posMaster.orgChild3Id == null
) {
shortName = posMaster.orgChild2.orgChild2ShortName;
orgId = posMaster.orgChild2Id;
orgId = posMaster.orgChild2Id;
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
@ -1498,7 +1492,7 @@ export class PositionController extends Controller {
posMaster.orgChild3Id !== null
) {
shortName = posMaster.orgChild3.orgChild3ShortName;
orgId = posMaster.orgChild3Id;
orgId = posMaster.orgChild3Id;
} else if (
posMaster.orgRootId !== null &&
posMaster.orgChild1Id !== null &&
@ -1506,7 +1500,7 @@ export class PositionController extends Controller {
posMaster.orgChild3Id !== null
) {
shortName = posMaster.orgChild4.orgChild4ShortName;
orgId = posMaster.orgChild4Id;
orgId = posMaster.orgChild4Id;
}
const positions = await this.positionRepository.find({
where: { posMasterId: posMaster.id },
@ -3596,6 +3590,7 @@ export class PositionController extends Controller {
const before = null;
dataMaster.isSit = requestBody.isSit;
dataMaster.next_holderId = requestBody.profileId;
dataMaster.lastUpdatedAt = new Date();
//add on
dataMaster.conditionReason = _null;
dataMaster.isCondition = false;
@ -4736,7 +4731,10 @@ export class PositionController extends Controller {
orgRevisionId: posMaster.orgRevisionId,
},
});
if (posMasterOld != null) posMasterOld.current_holderId = null;
if (posMasterOld != null) {
posMasterOld.current_holderId = null;
posMasterOld.lastUpdatedAt = new Date();
}
const positionOld = await this.positionRepository.findOne({
where: {
@ -4770,6 +4768,7 @@ export class PositionController extends Controller {
throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลทะเบียนประวัตินี้");
posMaster.current_holderId = body.profileId;
posMaster.lastUpdatedAt = new Date();
const _null: any = null;
posMaster.conditionReason = _null;
posMaster.isCondition = false;
@ -5323,6 +5322,7 @@ export class PositionController extends Controller {
if (!profile) throw new HttpError(HttpStatusCode.NOT_FOUND, "ไม่พบข้อมูลผู้ใช้งาน");
posMaster.next_holderId = requestBody.profileId;
posMaster.lastUpdatedAt = new Date();
posMaster.lastUpdateUserId = request.user.sub;
posMaster.lastUpdateFullName = request.user.name;
posMaster.lastUpdatedAt = new Date();