|
|
|
@ -756,16 +756,18 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
exports.consumption = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
|
const tanks = await Tank.find({ customerId });
|
|
|
|
|
const tanks = await Tank.find({ customerId,tankLocation:"overhead"});
|
|
|
|
|
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 waterlevel_at_midnight = parseInt(tank.waterlevel_at_midnight.replace(/,/g, ''), 10);
|
|
|
|
|
const total_water_added_from_midnight = parseInt(tank.total_water_added_from_midnight.replace(/,/g, ''), 10);
|
|
|
|
|
const waterlevel = parseInt(tank.waterlevel.replace(/,/g, ''), 10);
|
|
|
|
|
|
|
|
|
|
const tankname = tank.tankName
|
|
|
|
|
|
|
|
|
|
const consumption = (waterlevel_at_midnight+total_water_added_from_midnight)-waterlevel
|
|
|
|
|
|
|
|
|
|
const newWaterLevel = Math.floor(waterLevel);
|
|
|
|
|
const newWaterLevel = Math.floor(consumption);
|
|
|
|
|
tankData.push({ tankname, waterLevel: newWaterLevel });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|