|
|
@ -883,7 +883,7 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
if (action === "stop") {
|
|
|
|
if (action === "stop") {
|
|
|
|
await Tank.updateOne(
|
|
|
|
await Tank.updateOne(
|
|
|
|
{ customerId, "connections.inputConnections.motor_id": motorId },
|
|
|
|
{ customerId, "connections.inputConnections.motor_id": motorId },
|
|
|
|
{ $set: { "connections.inputConnections.$.motor_stop_status": "1" } }
|
|
|
|
{ $set: { "connections.inputConnections.$.motor_stop_status": "1",stopTime:req.body.stopTime } }
|
|
|
|
);
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
// Update the motor stop status to "2" for start action
|
|
|
|
// Update the motor stop status to "2" for start action
|
|
|
@ -917,7 +917,7 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
}, 60000); // Check water level every minute
|
|
|
|
}, 60000); // Check water level every minute
|
|
|
|
} else if (req.body.threshold_type === "litres") {
|
|
|
|
} else if (req.body.threshold_type === "litres") {
|
|
|
|
// If threshold type is percentage, calculate percentage threshold
|
|
|
|
// If threshold type is percentage, calculate percentage threshold
|
|
|
|
const receiver_tank_info = await Tank.findOne({ customerId, tankName: req.body.to, tankLocation: req.body.to_type.toLowerCase() });
|
|
|
|
const receiver_tank_info = await Tank.findOne({ customerId, tankName: req.body.to, tankLocation: req.body.to_type.toLowerCase(),startTime:req.body.startTime });
|
|
|
|
if (!receiver_tank_info) {
|
|
|
|
if (!receiver_tank_info) {
|
|
|
|
throw new Error("Receiver tank not found.");
|
|
|
|
throw new Error("Receiver tank not found.");
|
|
|
|
}
|
|
|
|
}
|
|
|
|