|
|
@ -1,5 +1,5 @@
|
|
|
|
//const Tank = require("../models/tanks");
|
|
|
|
//const Tank = require("../models/tanks");
|
|
|
|
const { Tank, MotorData, IotData,MotorIot,TankWaterLevel,TankConsumptionSchema } = require('../models/tanks')
|
|
|
|
const { Tank, MotorData, IotData,MotorIot,TankWaterLevel,TankConsumptionSchema,TankConsumptionOriginalSchema } = require('../models/tanks')
|
|
|
|
|
|
|
|
|
|
|
|
const {User} = require("../models/User");
|
|
|
|
const {User} = require("../models/User");
|
|
|
|
const boom = require("boom");
|
|
|
|
const boom = require("boom");
|
|
|
@ -940,7 +940,7 @@ let supplier_tanks = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.consumption = async (request, reply) => {
|
|
|
|
exports.consumption = async (request, reply) => {
|
|
|
|
try {SS
|
|
|
|
try {
|
|
|
|
const { customerId } = request.params;
|
|
|
|
const { customerId } = request.params;
|
|
|
|
const { startDate, stopDate, block, typeofwater } = request.body;
|
|
|
|
const { startDate, stopDate, block, typeofwater } = request.body;
|
|
|
|
|
|
|
|
|
|
|
@ -2370,7 +2370,7 @@ const updatetotalConsumptiontillmidnight = async () => {
|
|
|
|
const formattedDate = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm');
|
|
|
|
const formattedDate = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm');
|
|
|
|
|
|
|
|
|
|
|
|
// Check if the record already exists
|
|
|
|
// Check if the record already exists
|
|
|
|
const existingRecord = await TankConsumptionSchema.findOne({
|
|
|
|
const existingRecord = await TankConsumptionOriginalSchema.findOne({
|
|
|
|
customerId: tank.customerId,
|
|
|
|
customerId: tank.customerId,
|
|
|
|
tankName: tank.tankName,
|
|
|
|
tankName: tank.tankName,
|
|
|
|
tankLocation: tank.tankLocation,
|
|
|
|
tankLocation: tank.tankLocation,
|
|
|
@ -2379,7 +2379,7 @@ const updatetotalConsumptiontillmidnight = async () => {
|
|
|
|
|
|
|
|
|
|
|
|
if (!existingRecord) {
|
|
|
|
if (!existingRecord) {
|
|
|
|
// Create and save the new document if it doesn't exist
|
|
|
|
// Create and save the new document if it doesn't exist
|
|
|
|
const newTankConsumption = new TankConsumptionSchema({
|
|
|
|
const newTankConsumption = new TankConsumptionOriginalSchema({
|
|
|
|
customerId: tank.customerId,
|
|
|
|
customerId: tank.customerId,
|
|
|
|
tankName: tank.tankName,
|
|
|
|
tankName: tank.tankName,
|
|
|
|
tankLocation: tank.tankLocation,
|
|
|
|
tankLocation: tank.tankLocation,
|
|
|
@ -2428,7 +2428,7 @@ console.log('Scheduled task to update total consumption till midnight.');
|
|
|
|
// // Format the date in the desired format
|
|
|
|
// // Format the date in the desired format
|
|
|
|
// const formattedDate = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm');
|
|
|
|
// const formattedDate = moment().tz('Asia/Kolkata').format('DD-MMM-YYYY - HH:mm');
|
|
|
|
|
|
|
|
|
|
|
|
// const newTankConsumption = new TankConsumptionSchema({
|
|
|
|
// const newTankConsumption = new TankConsumptionOriginalSchema({
|
|
|
|
// customerId: tank.customerId,
|
|
|
|
// customerId: tank.customerId,
|
|
|
|
// tankName: tank.tankName,
|
|
|
|
// tankName: tank.tankName,
|
|
|
|
// tankLocation: tank.tankLocation,
|
|
|
|
// tankLocation: tank.tankLocation,
|
|
|
|