|
|
|
@ -8,6 +8,7 @@ const fastify = require("fastify")({
|
|
|
|
|
});
|
|
|
|
|
// const tanksController = require("./tanksController")
|
|
|
|
|
|
|
|
|
|
const moment = require('moment');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.addTanks = async (req, reply) => {
|
|
|
|
@ -27,6 +28,7 @@ console.log(req.params);
|
|
|
|
|
// console.log("This is the reply in the handler after the validations", reply);
|
|
|
|
|
tankData = {
|
|
|
|
|
customerId: customerId,
|
|
|
|
|
hardwareId: req.body.hardwareId,
|
|
|
|
|
tankName: req.body.tankName,
|
|
|
|
|
blockName: req.body.blockName,
|
|
|
|
|
capacity: req.body.capacity,
|
|
|
|
@ -52,6 +54,7 @@ console.log(req.params);
|
|
|
|
|
usertobeInserted = checkFormEncoding.tank;
|
|
|
|
|
console.log("thsi true url string");
|
|
|
|
|
tank.customerId = usertobeInserted.customerId
|
|
|
|
|
tank.hardwareId = usertobeInserted.hardwareId;
|
|
|
|
|
tank.tankName = usertobeInserted.tankName;
|
|
|
|
|
tank.blockName = usertobeInserted.blockName;
|
|
|
|
|
tank.capacity = usertobeInserted.capacity;
|
|
|
|
@ -663,8 +666,11 @@ exports.IotDevice = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { hardwareId, tankHeight, maxLevel, minLevel, mode } = req.body;
|
|
|
|
|
|
|
|
|
|
// create a new tank document with timestamp
|
|
|
|
|
const timestamp = moment().format('DD-MM-YY hh:mm:ss');
|
|
|
|
|
const tank = new IotData({ hardwareId, tankHeight, maxLevel, minLevel, mode, timestamp });
|
|
|
|
|
// create a new tank document
|
|
|
|
|
const tank = new IotData({ hardwareId, tankHeight, maxLevel, minLevel, mode });
|
|
|
|
|
// const tank = new IotData({ hardwareId, tankHeight, maxLevel, minLevel, mode });
|
|
|
|
|
|
|
|
|
|
// save the document to MongoDB
|
|
|
|
|
await tank.save();
|
|
|
|
|