|
|
|
@ -574,10 +574,8 @@ exports.createConnections = async (req, body) => {
|
|
|
|
|
capacity: data.capacity || null,
|
|
|
|
|
motor_status: data.motor_status || "0",
|
|
|
|
|
motor_stop_status: data.motor_stop_status || "1"
|
|
|
|
|
}], },
|
|
|
|
|
// 'connections.outputConnections': {
|
|
|
|
|
// $each: [{ outputConnections: tankname, output_type: 'overhead'}],
|
|
|
|
|
// },
|
|
|
|
|
}],
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{ new: true }
|
|
|
|
@ -588,12 +586,27 @@ exports.createConnections = async (req, body) => {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tank_connections;
|
|
|
|
|
const response = {
|
|
|
|
|
tank_connections,
|
|
|
|
|
water_level_percentage: calculateWaterLevelPercentage(req.body.water_level, req.body.capacity)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
reply.send({ status_code: 200, response: response});
|
|
|
|
|
|
|
|
|
|
} catch (err) {
|
|
|
|
|
throw boom.boomify(err);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function calculateWaterLevelPercentage(waterLevel, capacity) {
|
|
|
|
|
if (waterLevel && capacity) {
|
|
|
|
|
const percentage = (parseFloat(waterLevel) / parseFloat(capacity)) * 100;
|
|
|
|
|
return percentage.toFixed(2); // Return percentage with 2 decimal places
|
|
|
|
|
}
|
|
|
|
|
return null; // If waterLevel or capacity is missing, return null
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|