|
|
|
@ -160,9 +160,10 @@ exports.updateTanklevels = async (req, reply) => {
|
|
|
|
|
const tankId = tank._id;
|
|
|
|
|
const tank_name = tank.tankName
|
|
|
|
|
let capacity = parseInt(tank.capacity.replace(/,/g, ''), 10);
|
|
|
|
|
let waterLevel = parseInt(tank.waterlevel.replace(/,/g, ''), 10);
|
|
|
|
|
// let waterLevel = parseInt(tank.waterlevel.replace(/,/g, ''), 10);
|
|
|
|
|
|
|
|
|
|
const intervalId = setInterval(async function () {
|
|
|
|
|
let waterLevel = parseInt(tank.waterlevel.replace(/,/g, ''), 10);
|
|
|
|
|
const newWaterLevel = Math.floor(waterLevel - 200);
|
|
|
|
|
|
|
|
|
|
if (newWaterLevel <= 0) {
|
|
|
|
@ -201,33 +202,22 @@ exports.getTanklevels = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
|
|
|
|
|
|
const updated_data = await Tank.find({ customerId: customerId });
|
|
|
|
|
|
|
|
|
|
let sumSumpDrinkingWater = 0;
|
|
|
|
|
let sumOverheadDrinkingWater = 0;
|
|
|
|
|
const updated_data = await Tank.find({ customerId: customerId });
|
|
|
|
|
|
|
|
|
|
updated_data.forEach((tank) => {
|
|
|
|
|
if (tank.tankLocation === 'sump' && tank.typeOfWater === 'Drinking Water') {
|
|
|
|
|
sumSumpDrinkingWater += parseInt(tank.waterlevel);
|
|
|
|
|
} else if (tank.tankLocation === 'overhead' && tank.typeOfWater === 'Drinking Water') {
|
|
|
|
|
sumOverheadDrinkingWater += parseInt(tank.waterlevel);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
reply.send({ status_code: 200, data: updated_data});
|
|
|
|
|
|
|
|
|
|
reply.send({
|
|
|
|
|
status_code: 200,
|
|
|
|
|
data: updated_data,
|
|
|
|
|
totalDrinkingWaterInSump: sumSumpDrinkingWater,
|
|
|
|
|
totalDrinkingWaterInOverhead: sumOverheadDrinkingWater
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return { message: 'success' };
|
|
|
|
|
} catch (err) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
catch (err) {
|
|
|
|
|
throw boom.boomify(err);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.motorAction = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
//let start_time,stop_time
|
|
|
|
|