|
|
@ -169,12 +169,13 @@ exports.deleteTanksInfo = async (req, reply) => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.getConnectionsInfoOfParticularTank = async (req, reply) => {
|
|
|
|
exports.getConnectionsInfoOfParticularTank = async (req, reply) => {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
const tankName = req.body.tankName;
|
|
|
|
const tankName = req.body.tankName;
|
|
|
|
const tankLocation = req.body.tankLocation.toLowerCase();
|
|
|
|
const tankLocation = req.body.tankLocation.toLowerCase();
|
|
|
|
console.log(customerId,tankName,tankLocation)
|
|
|
|
console.log(customerId, tankName, tankLocation);
|
|
|
|
|
|
|
|
|
|
|
|
// Find the specific tank
|
|
|
|
// Find the specific tank
|
|
|
|
const mainTank = await Tank.findOne({
|
|
|
|
const mainTank = await Tank.findOne({
|
|
|
@ -204,14 +205,22 @@ exports.getConnectionsInfoOfParticularTank = async (req, reply) => {
|
|
|
|
const inputTanks = await Promise.all(inputTankPromises);
|
|
|
|
const inputTanks = await Promise.all(inputTankPromises);
|
|
|
|
const outputTanks = await Promise.all(outputTankPromises);
|
|
|
|
const outputTanks = await Promise.all(outputTankPromises);
|
|
|
|
|
|
|
|
|
|
|
|
// Combine data from the main tank and its connections
|
|
|
|
// Combine data from the main tank and its connections in a list with descriptive messages
|
|
|
|
const result = {
|
|
|
|
const resultList = [{
|
|
|
|
mainTank: mainTank,
|
|
|
|
type: 'Main Tank',
|
|
|
|
inputConnections: inputTanks.filter(tank => tank !== null), // Filter out null results
|
|
|
|
message: 'This is the data of the main tank.',
|
|
|
|
outputConnections: outputTanks.filter(tank => tank !== null) // Filter out null results
|
|
|
|
details: mainTank
|
|
|
|
};
|
|
|
|
}, {
|
|
|
|
|
|
|
|
type: 'Input Connections',
|
|
|
|
reply.send({ status_code: 200, data: result });
|
|
|
|
message: 'These are the data of all input tanks connected to the main tank.',
|
|
|
|
|
|
|
|
details: inputTanks.filter(tank => tank !== null) // Filter out null results
|
|
|
|
|
|
|
|
}, {
|
|
|
|
|
|
|
|
type: 'Output Connections',
|
|
|
|
|
|
|
|
message: 'These are the data of all output tanks connected to the main tank.',
|
|
|
|
|
|
|
|
details: outputTanks.filter(tank => tank !== null) // Filter out null results
|
|
|
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reply.send({ status_code: 200, data: resultList });
|
|
|
|
} catch (err) {
|
|
|
|
} catch (err) {
|
|
|
|
throw boom.boomify(err);
|
|
|
|
throw boom.boomify(err);
|
|
|
|
}
|
|
|
|
}
|
|
|
|