made changes in start and stop,created consumption

master
varun 3 years ago
parent 2a279e3ce4
commit 85c3f75ede

@ -248,7 +248,6 @@ exports.getTanklevels = async (req, reply) => {
exports.motorAction = async (req, reply) => {
try {
const customerId = req.params.customerId;
@ -377,23 +376,25 @@ exports.consumption = async (req, reply) => {
try {
const customerId = req.params.customerId;
const tanks = await Tank.find({ customerId });
const tankData = [];
for (const tank of tanks) {
const tankId = tank._id;
let capacity = parseInt(tank.capacity.replace(/,/g, ''), 10);
let waterLevel = capacity*2+1700; // initial water level
const tankname = tank.tankName
const newWaterLevel = Math.floor(waterLevel);
tankData.push({ tankname, waterLevel: newWaterLevel });
console.log(newWaterLevel);
// console.log(newWaterLevel);
}
reply.send({ status_code: 200, tankData });
return { message: 'Water level updates started' };
} catch (err) {
throw boom.boomify(err);
}
};

Loading…
Cancel
Save