made changes in iot create data

master
varun 2 years ago
parent 5fc6e57d9f
commit 7fd37b9065

@ -960,7 +960,7 @@ exports.calculateCapacity = async (req, reply) => {
exports.IotDevice = async (req, reply) => {
exports.IotDevice1 = async (req, reply) => {
try {
const { hardwareId, mode, tanks } = req.body;
@ -1208,3 +1208,33 @@ exports.deletemotordatarecordsbefore7days = async (req, reply) => {
throw boom.boomify(err);
}
};
exports.IotDevice = async (req, reply) => {
try {
// Schedule the task to run every day at 10 seconds past the minute
const { hardwareId, mode, tanks } = req.body;
// create a new tank document with the current date and time
const currentDate = new Date();
const date = currentDate.toISOString(); // save the date as an ISO string
const time = currentDate.toLocaleTimeString('en-IN', { hour12: false, timeZone: 'Asia/Kolkata' });
// Create an array of tank documents
const tankDocuments = tanks.map(tank => ({
tankhardwareId: tank.tankhardwareId,
tankHeight: tank.tankHeight,
maxLevel: tank.maxLevel,
minLevel: tank.minLevel,
date: date,
time: time
}));
reply.send({ status_code: 200,hardwareId:hardwareId, mode:mode, tanks:tanks,date: date,
time: time });
} catch (err) {
throw boom.boomify(err);
}
};

Loading…
Cancel
Save