changes in stop time in motoraction

master^2
Varun 9 months ago
parent abe8f01233
commit 1e9272faab

@ -2888,7 +2888,7 @@ exports.motorAction = async (req, reply) => {
// Perform stop operations in the background
(async () => {
await delay(300000);
const motorData = await MotorData.findOne({ customerId, motor_id: motorId, start_instance_id: start_instance_id });
if (motorData) {
@ -2947,6 +2947,7 @@ exports.motorAction = async (req, reply) => {
this.publishMotorStopStatus(motorId, motorStopStatus);
for await (const tank of Tank.find({ "connections.inputConnections.motor_id": motorId })) {
const index = tank.connections.inputConnections.findIndex(connection => connection.motor_id === motorId);
if (index !== -1) {
await Tank.updateOne(
{ customerId, "connections.inputConnections.motor_id": motorId },
@ -2978,7 +2979,7 @@ exports.motorAction = async (req, reply) => {
// fcmToken,
// `Motor has reached its time threshold of ${req.body.manual_threshold_time} minutes and will stop.`
// );
const currentTime = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm');
await Tank.updateOne(
{ customerId, "connections.inputConnections.motor_id": motorId },
{
@ -2987,7 +2988,8 @@ exports.motorAction = async (req, reply) => {
"connections.inputConnections.$.threshold_type": null,
"connections.inputConnections.$.manual_threshold_time": null,
"connections.inputConnections.$.manual_threshold_percentage": null
"connections.inputConnections.$.manual_threshold_percentage": null,
"connections.inputConnections.$.stopTime": currentTime,
}
}
);
@ -3015,7 +3017,7 @@ exports.motorAction = async (req, reply) => {
delete motorIntervals[motorId]; // Remove from interval object
this.publishMotorStopStatus(motorId, "1");
await delay(300000);
const motorData = await MotorData.findOne({ customerId, motor_id: motorId, start_instance_id: start_instance_id });
if (motorData) {
const receiverTank = await Tank.findOne({ customerId, tankName: motorData.receiverTank, tankLocation: motorData.receiver_type.toLowerCase() });
@ -3033,7 +3035,7 @@ exports.motorAction = async (req, reply) => {
{ customerId, motor_id: motorId, start_instance_id: start_instance_id },
{
$set: {
stopTime: req.body.stopTime,
stopTime: currentTime,
receiverfinalwaterlevel: receiverFinalWaterLevel.toString(),
quantity_delivered: quantityDelivered.toString()
}
@ -5716,6 +5718,8 @@ client.on('message', async (topic, message) => {
if (inputConnection.motor_stop_status === "2" && status === 1) {
inputConnection.motor_stop_status = "1";
const currentTime = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm');
inputConnection.stoptTime = currentTime;
// Emit motor stop notification with tankName
// eventEmitter.emit(

Loading…
Cancel
Save