diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 21bbad45..facf7ac7 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -262,11 +262,11 @@ exports.motorAction = async (req, reply) => { if(action === "start"){ - // start_time = new Date().toLocaleString('en-US', {timeZone: 'Asia/Kolkata'}) + start_time = new Date().toLocaleString('en-US', {timeZone: 'Asia/Kolkata'}) - supplier_tank = req.body.from - supplier_tank_type = (req.body.from_type).toLowerCase() - receiver_type = (req.body.to_type).toLowerCase() + const supplier_tank = req.body.from + const supplier_tank_type = (req.body.from_type).toLowerCase() + const receiver_type = (req.body.to_type).toLowerCase() console.log(supplier_tank) @@ -275,7 +275,7 @@ exports.motorAction = async (req, reply) => { const supplier_tank_info1 = await Tank.findOne({ customerId ,tankName:supplier_tank,tankLocation:supplier_tank_type}); console.log(supplier_tank_info1) - initial_update = parseInt(supplier_tank_info1.capacity.replace(/,/g, ''), 10)-200; + const initial_update = parseInt(supplier_tank_info1.capacity.replace(/,/g, ''), 10)-200; await Tank.findOneAndUpdate({customerId, tankName: supplier_tank,tankLocation:supplier_tank_type}, { $set: { waterlevel: initial_update } }); const supplier_tank_info = await Tank.findOne({ customerId ,tankName:supplier_tank,tankLocation:supplier_tank_type}); @@ -421,24 +421,25 @@ exports.motorAction = async (req, reply) => { } const motor_data = await motorData.save(); - reply.send({ status_code: 200, data: motor_data }); - return motor_data - + //reply.send({ status_code: 200, data: motor_data }); + - // reply.send({ status_code: 200, "start time": start_time}); + reply.send({ status_code: 200, "start time": start_time,data: motor_data}); + return motor_data + //console.log(start_time) } else if (action === "stop") { - // stop_time = new Date().toLocaleString('en-US', {timeZone: 'Asia/Kolkata'}) + stop_time = new Date().toLocaleString('en-US', {timeZone: 'Asia/Kolkata'}) // console.log(stop_time) // clearInterval(intervalId); await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:(req.body.to_type).toLowerCase()}, { $set: { motor_status: "0" } }); - // reply.send({ status_code: 200, "stop time": stop_time}); + reply.send({ status_code: 200, "stop time": stop_time}); } else { throw new Error("Invalid action"); }