From a222714bcbbabb2cba18f56b9cc7f6016912f77a Mon Sep 17 00:00:00 2001 From: Mohamad Ihsan Date: Tue, 21 Feb 2023 19:07:02 +0700 Subject: [PATCH] update --- .../modules/loadbalance/loadbalance.model.js | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/application/modules/loadbalance/loadbalance.model.js b/application/modules/loadbalance/loadbalance.model.js index 951e38c..f413976 100644 --- a/application/modules/loadbalance/loadbalance.model.js +++ b/application/modules/loadbalance/loadbalance.model.js @@ -288,6 +288,10 @@ const insertLoadingBalance = async ( .insert(data) .returning('i_load_balance') .then((resp) => { + winston.logger.warn( + `${uniqueCode} inserting loading balance 1 ${JSON.stringify(resp)}` + ); + let id = resp[0]; let loadDetail = []; detail.forEach((element) => { @@ -313,6 +317,8 @@ const insertLoadingBalance = async ( .insert(loadDetail); }) .then(() => { + winston.logger.warn(`${uniqueCode} inserting loading balance 2...}`); + // insert load balance history return knex('trx.t_d_load_balance_history') .transacting(trx) @@ -320,6 +326,12 @@ const insertLoadingBalance = async ( .insert(data); }) .then((history) => { + winston.logger.warn( + `${uniqueCode} inserting loading balance 3 ${JSON.stringify( + history + )}` + ); + let id = history[0]; let loadDetail = []; detail.forEach((element) => { @@ -345,6 +357,8 @@ const insertLoadingBalance = async ( .insert(loadDetail); }) .then(() => { + winston.logger.warn(`${uniqueCode} inserting loading balance 4...}`); + // update reservation return knex('trx.t_d_reservation_balance') .transacting(trx) @@ -363,6 +377,8 @@ const insertLoadingBalance = async ( .whereIn('c_reservation_no', reservationNumber); }) .then(() => { + winston.logger.warn(`${uniqueCode} inserting loading balance 5...}`); + // delete flag counting return knex('trx.t_d_flag_counting') .transacting(trx) @@ -371,6 +387,8 @@ const insertLoadingBalance = async ( .del(); }) .then(() => { + winston.logger.warn(`${uniqueCode} inserting loading balance 6...}`); + // insert flag counting return knex('trx.t_d_flag_counting').transacting(trx).insert({ d_request: now, @@ -380,7 +398,13 @@ const insertLoadingBalance = async ( c_flag: flag, }); }) - .then(trx.commit) + .then(() => { + winston.logger.warn( + `${uniqueCode} inserting loading balance 7 COMMIT... }` + ); + + trx.commit; + }) .catch((err) => { winston.logger.warn( `${uniqueCode} ERRORRRRRRR ROLLBACK ${JSON.stringify(err.message)}` @@ -389,13 +413,19 @@ const insertLoadingBalance = async ( }); }) .then((result) => { + winston.logger.warn( + `${uniqueCode} inserting loading balance 8 ${JSON.stringify(result)}` + ); + // console.log(result); return result; }) .catch((error) => { console.log(error.message); winston.logger.warn( - `${uniqueCode} ERRORRRRRRR CATCH ${JSON.stringify(err.message)}` + `${uniqueCode} inserting loadbalance 9 ERRORRRRRRR CATCH ${JSON.stringify( + err.message + )}` ); return error.message; });