diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 336ad056..c4dff7f1 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -3059,7 +3059,9 @@ exports.motorAction = async (req, reply) => { console.log("got into if") const receiverTank = await Tank.findOne({ customerId, tankName: motorData.receiverTank, tankLocation: motorData.receiver_type.toLowerCase() }); const receiverFinalWaterLevel = parseInt(receiverTank.waterlevel, 10); + console.log(receiverFinalWaterLevel,"receiverFinalWaterLevel") const quantityDelivered = receiverFinalWaterLevel - parseInt(motorData.receiverInitialwaterlevel, 10); + console.log(quantityDelivered,"quantityDelivered") const water_pumped_till_now = parseInt(receiverTank.total_water_added_from_midnight, 10); const totalwaterpumped = quantityDelivered + water_pumped_till_now; const start = moment(motorData.startTime, 'DD-MMM-YYYY - HH:mm'); @@ -3136,7 +3138,7 @@ exports.motorAction = async (req, reply) => { const supplier_threshold = supplier_waterLevel-desired_percentage console.log(supplier_threshold,"supplier_threshold") - for await (const tank of Tank.find({ "connections.inputConnections.motor_id": motorId })) { + this.publishMotorStopStatus(motorId, motorStopStatus); for await (const tank of Tank.find({ "connections.inputConnections.motor_id": motorId })) { const index = tank.connections.inputConnections.findIndex(connection => connection.motor_id === motorId); @@ -3200,7 +3202,7 @@ exports.motorAction = async (req, reply) => { } } }, 20000); - } + } @@ -6133,6 +6135,11 @@ async function processIotData(hw_Id, data) { inputConnection.motor_stop_status = "1"; inputConnection.motor_on_type = "manual"; inputConnection.stopTime = currentTime; + if (motorIntervals[motorId]) { + clearInterval(motorIntervals[motorId]); + delete motorIntervals[motorId]; + console.log("motor interval deleted") + } } await motorTank.save();