|
|
|
@ -360,6 +360,14 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
const receiver_capacity = parseInt(receiver_tank_info.capacity.replace(/,/g, ''), 10)
|
|
|
|
|
// console.log(receiver_capacity,"0",receiver_tank_info.tankName)
|
|
|
|
|
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "1" } });
|
|
|
|
|
const sumpTank = await Tank.findOne({ customerId, tankName: receiver_tank, tankLocation: receiver_type });
|
|
|
|
|
const connection = sumpTank.connections.inputConnections.find((conn) => conn.inputConnections === supplier_tank);
|
|
|
|
|
|
|
|
|
|
if (connection) {
|
|
|
|
|
connection.motor_status = "1";
|
|
|
|
|
await sumpTank.save();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let receiver_waterlevel = parseInt(receiver_tank_info.waterlevel.replace(/,/g, ''), 10)
|
|
|
|
|
// console.log(receiver_waterlevel,"1")
|
|
|
|
@ -376,6 +384,13 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
await Tank.findOneAndUpdate({customerId, tankName: receiver_tank,tankLocation:receiver_type}, { $set: { motor_status: "0" } });
|
|
|
|
|
clearInterval(intervals[receiver_tank]); // Clear the interval for this tank
|
|
|
|
|
delete intervals[receiver_tank];
|
|
|
|
|
const sumpTank = await Tank.findOne({ customerId, tankName: receiver_tank, tankLocation: receiver_type });
|
|
|
|
|
const connection = sumpTank.connections.inputConnections.find((conn) => conn.inputConnections === supplier_tank);
|
|
|
|
|
|
|
|
|
|
if (connection) {
|
|
|
|
|
connection.motor_status = "0";
|
|
|
|
|
await sumpTank.save();
|
|
|
|
|
}
|
|
|
|
|
console.log("end for" + receiver_tank);
|
|
|
|
|
} else {
|
|
|
|
|
// Update water levels in database
|
|
|
|
|