ashok 1 year ago
commit 86aeb3e92c

@ -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,

@ -151,6 +151,16 @@ const tankconsumptionSchema = new mongoose.Schema({
time: { type: String } time: { type: String }
}); });
const tankconsumptionoriginalSchema = new mongoose.Schema({
customerId: { type: String },
tankName: { type: String },
tankLocation: { type: String },
consumption: { type: String },
block:{type: String},
typeofwater:{type:String},
time: { type: String }
});
const Tank = mongoose.model("Tank", tanksSchema); const Tank = mongoose.model("Tank", tanksSchema);
@ -158,8 +168,10 @@ const MotorData = mongoose.model("MotorData", motordataSchema);
const TankWaterLevel = mongoose.model("TankWaterLevel", tankWaterLevelSchema); const TankWaterLevel = mongoose.model("TankWaterLevel", tankWaterLevelSchema);
const IotData = mongoose.model("IotData", IOttankSchema); const IotData = mongoose.model("IotData", IOttankSchema);
const TankConsumptionSchema = mongoose.model("TankConsumptionSchema", tankconsumptionSchema); const TankConsumptionSchema = mongoose.model("TankConsumptionSchema", tankconsumptionSchema);
const TankConsumptionOriginalSchema = mongoose.model("TankConsumptionOriginalSchema", tankconsumptionoriginalSchema);
module.exports = { module.exports = {
Tank, MotorData,IotData,TankWaterLevel,TankConsumptionSchema Tank, MotorData,IotData,TankWaterLevel,TankConsumptionSchema,TankConsumptionOriginalSchema
} }

Loading…
Cancel
Save