|
|
|
@ -352,10 +352,17 @@ exports.getTanksofParticularInstaller = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
exports.getTankmotordata = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { startDate, stopDate, block } = req.body;
|
|
|
|
|
const { startDate, stopDate } = req.body;
|
|
|
|
|
const { customerId } = req.params;
|
|
|
|
|
const start = moment(startDate, "DD-MMM-YYYY - HH:mm").toDate();
|
|
|
|
|
const end = moment(stopDate, "DD-MMM-YYYY - HH:mm").toDate();
|
|
|
|
|
|
|
|
|
|
// Parse the input startDate and stopDate using the desired format
|
|
|
|
|
// const start = moment(startDate, "DD-MMM-YYYY - HH:mm").toDate();
|
|
|
|
|
// const end = moment(stopDate, "DD-MMM-YYYY - HH:mm").toDate();
|
|
|
|
|
// console.log(start,"start",end,"end")
|
|
|
|
|
// Check if the parsed dates are valid
|
|
|
|
|
|
|
|
|
|
// Convert the dates to the correct format for storage or querying (still in UTC)
|
|
|
|
|
// This gives a native JS Date object for querying
|
|
|
|
|
|
|
|
|
|
// Fetch the name from the User collection based on customerId, only from profile
|
|
|
|
|
const user = await User.findOne({ customerId })
|
|
|
|
@ -370,14 +377,11 @@ exports.getTankmotordata = async (req, reply) => {
|
|
|
|
|
// Construct the query object for motor data based on customerId
|
|
|
|
|
const motorQuery = { customerId };
|
|
|
|
|
|
|
|
|
|
// If block is provided (and not "All"), add it to the query
|
|
|
|
|
if (block !== "All") motorQuery.block = block;
|
|
|
|
|
|
|
|
|
|
// Fetch motor data for the customerId within the time range
|
|
|
|
|
const motorDataDocs = await MotorData.find(motorQuery)
|
|
|
|
|
.where("date")
|
|
|
|
|
.gte(start) // Greater than or equal to startDate
|
|
|
|
|
.lte(end) // Less than or equal to stopDate
|
|
|
|
|
.where("startTime")
|
|
|
|
|
.gte(startDate) // Greater than or equal to startDate
|
|
|
|
|
.lte(stopDate) // Less than or equal to stopDate
|
|
|
|
|
.exec();
|
|
|
|
|
|
|
|
|
|
reply.send({
|
|
|
|
@ -396,6 +400,10 @@ exports.getTankmotordata = async (req, reply) => {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.updateTanklevels = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const customerId = req.params.customerId;
|
|
|
|
|