|
|
|
@ -779,10 +779,11 @@ exports.masterConnectedSlaveList = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
exports.mastrerList = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { customerId } = req.params;
|
|
|
|
|
const { customerId, installationId } = req.params;
|
|
|
|
|
|
|
|
|
|
// Step 1: Get User and extract buildingName
|
|
|
|
|
const user = await User.findOne({ customerId });
|
|
|
|
|
const user = await User.findOne({ customerId , installationId
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!user) {
|
|
|
|
|
return reply.status(404).send({ success: false, message: "User not found" });
|
|
|
|
@ -800,9 +801,9 @@ exports.mastrerList = async (req, reply) => {
|
|
|
|
|
// Step 3: Extract hardwareId from tanks
|
|
|
|
|
const hardwareIds = tanks.map(tank => tank.hardwareId);
|
|
|
|
|
|
|
|
|
|
// Step 4: Find master tanks in InSensors with customerId filter
|
|
|
|
|
// Step 4: Find master tanks in InSensors with both customerId and installationId
|
|
|
|
|
const masterTanks = await Insensors.find({
|
|
|
|
|
customerId, // Ensure only this customer’s data is fetched
|
|
|
|
|
customerId,
|
|
|
|
|
connected_to: { $in: hardwareIds },
|
|
|
|
|
type: "master"
|
|
|
|
|
});
|
|
|
|
|