diff --git a/src/controllers/CommandController.ts b/src/controllers/CommandController.ts index 6724eabb..9fbf9199 100644 --- a/src/controllers/CommandController.ts +++ b/src/controllers/CommandController.ts @@ -6673,23 +6673,11 @@ export class CommandController extends Controller { }; try { - // 8. บันทึกข้อมูลใหม่ - const dataAct = new ProfileActposition(); - Object.assign(dataAct, metaAct); - - const historyAct = new ProfileActpositionHistory(); - Object.assign(historyAct, { ...dataAct, id: undefined }); - - await this.actpositionRepository.save(dataAct); - historyAct.profileActpositionId = dataAct.id; - await this.actpositionHistoryRepository.save(historyAct); - - // 9. ปิดสถานะรักษาการ + // 8. ปิดสถานะรักษาการ const existingActPositions = await this.actpositionRepository.find({ where: { profileId: item.posMasterChild.current_holderId, status: true, - id: Not(dataAct.id), }, }); @@ -6702,6 +6690,17 @@ export class CommandController extends Controller { await this.actpositionRepository.save(updatedActPositions); } + + // 9. บันทึกข้อมูลใหม่ + const dataAct = new ProfileActposition(); + Object.assign(dataAct, metaAct); + + const historyAct = new ProfileActpositionHistory(); + Object.assign(historyAct, { ...dataAct, id: undefined }); + + await this.actpositionRepository.save(dataAct); + historyAct.profileActpositionId = dataAct.id; + await this.actpositionHistoryRepository.save(historyAct); } catch (error) { console.error(`Error processing item ${item.id}:`, error); throw new HttpError(