|
|
|
@ -3099,6 +3099,11 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
const quantityDelivered = receiverFinalWaterLevel - parseInt(motorData.receiverInitialwaterlevel, 10);
|
|
|
|
|
const water_pumped_till_now = parseInt(receiverTank.total_water_added_from_midnight, 10);
|
|
|
|
|
const totalwaterpumped = quantityDelivered + water_pumped_till_now;
|
|
|
|
|
const start = moment(motorData.startTime, 'DD-MMM-YYYY - HH:mm');
|
|
|
|
|
const stop = moment(currentTime, 'DD-MMM-YYYY - HH:mm');
|
|
|
|
|
const duration = moment.duration(stop.diff(start));
|
|
|
|
|
const runtime = Math.floor(duration.asMinutes()); // runtime in minutes
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await Tank.findOneAndUpdate(
|
|
|
|
|
{ customerId, tankName: motorData.receiverTank, tankLocation: motorData.receiver_type.toLowerCase() },
|
|
|
|
@ -3111,7 +3116,8 @@ exports.motorAction = async (req, reply) => {
|
|
|
|
|
$set: {
|
|
|
|
|
stopTime: currentTime,
|
|
|
|
|
receiverfinalwaterlevel: receiverFinalWaterLevel.toString(),
|
|
|
|
|
quantity_delivered: quantityDelivered.toString()
|
|
|
|
|
quantity_delivered: quantityDelivered.toString(),
|
|
|
|
|
runtime: runtime.toString()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
@ -3281,8 +3287,10 @@ async function stopMotor(motorId, customerId, start_instance_id) {
|
|
|
|
|
|
|
|
|
|
const motorData = await MotorData.findOne({ customerId, motor_id: motorId, start_instance_id });
|
|
|
|
|
if (motorData) {
|
|
|
|
|
const startTime = moment(motorData.startTime, 'DD-MMM-YYYY - HH:mm');
|
|
|
|
|
const runtime = moment.duration(moment(currentTime, 'DD-MMM-YYYY - HH:mm').diff(startTime)).asSeconds();
|
|
|
|
|
const start = moment(motorData.startTime, 'DD-MMM-YYYY - HH:mm');
|
|
|
|
|
const stop = moment(currentTime, 'DD-MMM-YYYY - HH:mm');
|
|
|
|
|
const duration = moment.duration(stop.diff(start));
|
|
|
|
|
const runtime = Math.floor(duration.asMinutes()); // runtime in minutes
|
|
|
|
|
|
|
|
|
|
const receiverTank = await Tank.findOne({ customerId, tankName: motorData.receiverTank, tankLocation: motorData.receiver_type.toLowerCase() });
|
|
|
|
|
const receiverFinalWaterLevel = parseInt(receiverTank.waterlevel.replace(/,/g, ''), 10);
|
|
|
|
|