diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index c875b36a..c95ed3c5 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -2856,7 +2856,7 @@ exports.motorAction = async (req, reply) => { receiver_type: req.body.to_type, startTime: req.body.startTime, receiverInitialwaterlevel: parseInt(receiverTank.waterlevel, 10), - started_by:loggedInUser + started_by:loggedInUser.name }); await newMotorData.save(); console.log("entered time",motorId,motorStopStatus) @@ -3025,7 +3025,7 @@ exports.motorAction = async (req, reply) => { startTime: req.body.startTime, receiverInitialwaterlevel:parseInt(receiver_tank_info7.waterlevel, 10), supplierInitialwaterlevel:parseInt(supplier_tank_info7.waterlevel, 10), - started_by:loggedInUser + started_by:loggedInUser.name }); await newMotorData.save(); // If threshold type is percentage, calculate percentage threshold @@ -3107,7 +3107,7 @@ exports.motorAction = async (req, reply) => { stopTime:stopTime, receiverfinalwaterlevel: receiverFinalWaterLevel.toString(), quantity_delivered: quantityDelivered.toString(), - stopped_by:loggedInUser + stopped_by:loggedInUser.name } } ); @@ -3126,7 +3126,7 @@ exports.motorAction = async (req, reply) => { }); let dynamicInstanceId = null; - + let user_name = loggedInUser.name if (tankWithMotor) { const connection = tankWithMotor.connections.inputConnections.find(conn => conn.motor_id === motorId); if (connection && connection.start_instance_id) { @@ -3134,7 +3134,7 @@ exports.motorAction = async (req, reply) => { } } - await stopMotor(motorId, customerId, dynamicInstanceId,loggedInUser); + await stopMotor(motorId, customerId, dynamicInstanceId,user_name); try { @@ -3171,7 +3171,7 @@ exports.motorAction = async (req, reply) => { }; -async function stopMotor(motorId, customerId, start_instance_id,loggedInUser) { +async function stopMotor(motorId, customerId, start_instance_id,user_name) { const currentTime = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm'); await Tank.updateOne( { customerId, "connections.inputConnections.motor_id": motorId }, @@ -3205,7 +3205,7 @@ async function stopMotor(motorId, customerId, start_instance_id,loggedInUser) { await MotorData.updateOne( { customerId, motor_id: motorId, start_instance_id }, - { $set: { stopTime: currentTime, receiverfinalwaterlevel: receiverFinalWaterLevel.toString(), quantity_delivered: quantityDelivered.toString(), runtime: runtime,stopped_by:loggedInUser } } + { $set: { stopTime: currentTime, receiverfinalwaterlevel: receiverFinalWaterLevel.toString(), quantity_delivered: quantityDelivered.toString(), runtime: runtime,stopped_by:user_name } } ); } }