added started by and stopped by in motordata

master^2
Varun 6 months ago
parent 11e76a6d82
commit ba19fba6e0

@ -2854,7 +2854,8 @@ exports.motorAction = async (req, reply) => {
supplier_type: req.body.from_type,
receiver_type: req.body.to_type,
startTime: req.body.startTime,
receiverInitialwaterlevel: parseInt(receiverTank.waterlevel, 10)
receiverInitialwaterlevel: parseInt(receiverTank.waterlevel, 10),
started_by:loggedInUser
});
await newMotorData.save();
console.log("entered time",motorId,motorStopStatus)
@ -2989,7 +2990,8 @@ exports.motorAction = async (req, reply) => {
stopTime: currentTime,
receiverfinalwaterlevel: receiverFinalWaterLevel.toString(),
quantity_delivered: quantityDelivered.toString(),
runtime: runtime.toString()
runtime: runtime.toString(),
stopped_by:loggedInUser
}
}
);
@ -3021,7 +3023,8 @@ exports.motorAction = async (req, reply) => {
receiver_type: req.body.to_type,
startTime: req.body.startTime,
receiverInitialwaterlevel:parseInt(receiver_tank_info7.waterlevel, 10),
supplierInitialwaterlevel:parseInt(supplier_tank_info7.waterlevel, 10)
supplierInitialwaterlevel:parseInt(supplier_tank_info7.waterlevel, 10),
started_by:loggedInUser
});
await newMotorData.save();
// If threshold type is percentage, calculate percentage threshold
@ -3102,7 +3105,8 @@ exports.motorAction = async (req, reply) => {
$set: {
stopTime:stopTime,
receiverfinalwaterlevel: receiverFinalWaterLevel.toString(),
quantity_delivered: quantityDelivered.toString()
quantity_delivered: quantityDelivered.toString(),
stopped_by:loggedInUser
}
}
);
@ -3129,7 +3133,7 @@ exports.motorAction = async (req, reply) => {
}
}
await stopMotor(motorId, customerId, dynamicInstanceId);
await stopMotor(motorId, customerId, dynamicInstanceId,loggedInUser);
try {
@ -3166,7 +3170,7 @@ exports.motorAction = async (req, reply) => {
};
async function stopMotor(motorId, customerId, start_instance_id) {
async function stopMotor(motorId, customerId, start_instance_id,loggedInUser) {
const currentTime = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm');
await Tank.updateOne(
{ customerId, "connections.inputConnections.motor_id": motorId },
@ -3200,7 +3204,7 @@ async function stopMotor(motorId, customerId, start_instance_id) {
await MotorData.updateOne(
{ customerId, motor_id: motorId, start_instance_id },
{ $set: { stopTime: currentTime, receiverfinalwaterlevel: receiverFinalWaterLevel.toString(), quantity_delivered: quantityDelivered.toString(), runtime: runtime } }
{ $set: { stopTime: currentTime, receiverfinalwaterlevel: receiverFinalWaterLevel.toString(), quantity_delivered: quantityDelivered.toString(), runtime: runtime,stopped_by:loggedInUser } }
);
}
}
@ -6094,7 +6098,8 @@ async function processIotData(hw_Id, data) {
supplier_type: inputConnection.input_type,
receiver_type: motorTank.tankLocation,
startTime: formattedTime,
receiverInitialwaterlevel: parseInt(inputConnection.water_level, 10)
receiverInitialwaterlevel: parseInt(inputConnection.water_level, 10),
started_by:"manual"
});
await newMotorData.save();
@ -6143,7 +6148,8 @@ async function processIotData(hw_Id, data) {
stopTime: currentTime,
receiverfinalwaterlevel: receiverFinalWaterLevel.toString(),
quantity_delivered: quantityDelivered.toString(),
runtime: runtime.toString()
runtime: runtime.toString(),
stopped_by:"manual"
}
}
);

@ -142,7 +142,8 @@ const motordataSchema = new mongoose.Schema({
quantity_delivered:{ type: String, default: null },
receiverInitialwaterlevel: { type: String, default: "0" },
receiverfinalwaterlevel: { type: String, default: "0" },
started_by: { type: String, default: "user" },
stopped_by: { type: String, default: "user" }
});

Loading…
Cancel
Save