|
|
|
@ -1051,6 +1051,7 @@ let supplier_tanks = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.consumption = async (request, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { customerId } = request.params;
|
|
|
|
@ -1622,15 +1623,15 @@ eventEmitter.on(
|
|
|
|
|
console.log("users", users);
|
|
|
|
|
const userNames = users.map(user => user.username).join(', ');
|
|
|
|
|
console.log("userNames", userNames);
|
|
|
|
|
const startMethod = motorOnType === "APP" ? "via the App" : "Manual";
|
|
|
|
|
const startMethod = motorOnType.toUpperCase() === "APP" ? "via the App" : "Manual";
|
|
|
|
|
|
|
|
|
|
// Prepare the message
|
|
|
|
|
const message =
|
|
|
|
|
`🚰 Tank Name: '${tankName}'\n` +
|
|
|
|
|
`🕒 Pump started at: '${startTime}'\n` +
|
|
|
|
|
`👤 Initiated by : ${userNames}\n` +
|
|
|
|
|
`Tank Name: '${tankName}'\n` +
|
|
|
|
|
`Pump started at: '${startTime}'\n` +
|
|
|
|
|
`Initiated by : ${userNames}\n` +
|
|
|
|
|
// `Pump started by: '${motorOnType.toUpperCase()}'\n` +
|
|
|
|
|
`🔄 Pump started by: '${startMethod}'\n` +
|
|
|
|
|
`Pump started by: '${startMethod}'\n` +
|
|
|
|
|
`Will stop at after: '${manual_threshold_time}' mins`;
|
|
|
|
|
|
|
|
|
|
// Send the notification
|
|
|
|
@ -1650,14 +1651,14 @@ eventEmitter.on('motorStop', async (fcmTokens, tankName,stopTime, motorOnType)
|
|
|
|
|
const userNames = users.map(user => user.username).join(', ');
|
|
|
|
|
console.log("userNames",userNames)
|
|
|
|
|
|
|
|
|
|
const stopMethod = motorOnType === "APP" ? "via the App" : "manual";
|
|
|
|
|
const stopMethod = motorOnType.toUpperCase() === "APP" ? "via the App" : "manual";
|
|
|
|
|
|
|
|
|
|
// Prepare the message
|
|
|
|
|
// const message = `Tank Name: '${tankName}', Pump stopped at '${stopTime}' by Initiated by user(s): ${userNames} '${motorOnType}'`;
|
|
|
|
|
const message =
|
|
|
|
|
`🚰 Tank Name: '${tankName}'\n` +
|
|
|
|
|
`🕒 Pump stopped at: '${stopTime}'\n` +
|
|
|
|
|
`👤 Initiated by : ${userNames}\n` +
|
|
|
|
|
`Tank Name: '${tankName}'\n` +
|
|
|
|
|
`Pump stopped at: '${stopTime}'\n` +
|
|
|
|
|
`Initiated by : ${userNames}\n` +
|
|
|
|
|
// `Motor Off Type: '${motorOnType}'`;
|
|
|
|
|
`Motor Off Type: '${stopMethod}'`;
|
|
|
|
|
|
|
|
|
@ -1755,7 +1756,7 @@ eventEmitter.on(
|
|
|
|
|
// Retrieve the user information
|
|
|
|
|
const users = await User.find({ fcmIds: { $in: fcmTokens } });
|
|
|
|
|
const userNames = users.map(user => user.username).join(', ');
|
|
|
|
|
const startMethod = motorOnType === "Forced Manual";
|
|
|
|
|
const startMethod = motorOnType.toUpperCase() === "Forced Manual";
|
|
|
|
|
|
|
|
|
|
// Prepare the message
|
|
|
|
|
const message =
|
|
|
|
@ -1783,14 +1784,14 @@ eventEmitter.on(
|
|
|
|
|
// Retrieve the user information
|
|
|
|
|
const users = await User.find({ fcmIds: { $in: fcmTokens } });
|
|
|
|
|
const userNames = users.map(user => user.username).join(', ');
|
|
|
|
|
const stopMethod = motorOnType === "Forced Manual";
|
|
|
|
|
const stopMethod = motorOnType.toUpperCase() === "Forced Manual";
|
|
|
|
|
|
|
|
|
|
// Prepare the message
|
|
|
|
|
const message =
|
|
|
|
|
`🚰 Tank Name: '${tankName}'\n` +
|
|
|
|
|
`🕒 Pump stopped at: '${stopTime}'\n` +
|
|
|
|
|
`👤 Initiated by: ${userNames}\n` +
|
|
|
|
|
`Motor Off Type: '${stopMethod}'\n`;
|
|
|
|
|
`🔄 Pump stopped by: '${stopMethod}'\n`;
|
|
|
|
|
|
|
|
|
|
// Send the notification
|
|
|
|
|
await sendNotification(fcmTokens, 'Motor Stopped 🛑', message);
|
|
|
|
@ -2410,7 +2411,7 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
blockName,
|
|
|
|
|
tankName,
|
|
|
|
|
startTime,
|
|
|
|
|
"APP",
|
|
|
|
|
motorOnType,
|
|
|
|
|
manual_threshold_time
|
|
|
|
|
);
|
|
|
|
|
notificationSentStatus.motorStart = true; // Set flag to true to prevent duplicate notifications
|
|
|
|
@ -2458,7 +2459,7 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
fcmToken,
|
|
|
|
|
tankName,
|
|
|
|
|
stopTime,
|
|
|
|
|
"APP"
|
|
|
|
|
motorOnType
|
|
|
|
|
);
|
|
|
|
|
notificationSentStatus.motorStop = true; // Set flag to true to prevent duplicate notifications
|
|
|
|
|
}
|
|
|
|
|