|
|
|
@ -6200,9 +6200,9 @@ async function processIotData(hw_Id, data) {
|
|
|
|
|
for (const tank of tanks) {
|
|
|
|
|
const { Id: tankhardwareId, level: tankHeight } = tank;
|
|
|
|
|
const existingTank = await Tank.findOne({ hardwareId: hw_Id, tankhardwareId });
|
|
|
|
|
console.log(hw_Id,"hw_Id")
|
|
|
|
|
console.log(tankhardwareId,"tankhardwareId")
|
|
|
|
|
console.log(existingTank,"existingTank")
|
|
|
|
|
// console.log(hw_Id,"hw_Id")
|
|
|
|
|
// console.log(tankhardwareId,"tankhardwareId")
|
|
|
|
|
// console.log(existingTank,"existingTank")
|
|
|
|
|
if (!existingTank) continue;
|
|
|
|
|
|
|
|
|
|
const customerId = existingTank.customerId;
|
|
|
|
@ -6223,14 +6223,15 @@ async function processIotData(hw_Id, data) {
|
|
|
|
|
existingTank.slave_status = "signal_lost1";
|
|
|
|
|
existingTank.slave_signal_lost_time = now.format('DD-MMM-YYYY - HH:mm:ss');
|
|
|
|
|
await existingTank.save();
|
|
|
|
|
|
|
|
|
|
console.log(now.format('DD-MMM-YYYY - HH:mm:ss'),"in signal lost")
|
|
|
|
|
console.log(`⚠️ Signal lost for tank [${tankhardwareId}] at ${existingTank.slave_signal_lost_time}`);
|
|
|
|
|
|
|
|
|
|
} else if (existingTank.slave_status === "signal_lost1") {
|
|
|
|
|
const lostTime = moment(existingTank.slave_signal_lost_time, 'DD-MMM-YYYY - HH:mm:ss');
|
|
|
|
|
const minutesElapsed = now.diff(lostTime, 'minutes');
|
|
|
|
|
|
|
|
|
|
console.log(now.format('DD-MMM-YYYY - HH:mm:ss'),"in comparing signal lost")
|
|
|
|
|
if (minutesElapsed >= 15) {
|
|
|
|
|
console.log(now.format('DD-MMM-YYYY - HH:mm:ss'),"in not_working")
|
|
|
|
|
existingTank.slave_status = "not_working";
|
|
|
|
|
existingTank.slave_disconnected_time = now.format('DD-MMM-YYYY - HH:mm:ss');
|
|
|
|
|
await existingTank.save();
|
|
|
|
|