diff --git a/src/controllers/supplierOrderController.js b/src/controllers/supplierOrderController.js index 1f56b1c9..96e3f2f2 100644 --- a/src/controllers/supplierOrderController.js +++ b/src/controllers/supplierOrderController.js @@ -625,9 +625,9 @@ exports.getAllOrderreject = async (req, reply) => { const limit = parseInt(req.query.limit) || 100; const page = parseInt(req.query.page) || 1; const startindex = (page - 1) * limit; - const customerId = req.params.customerId + //const customerId = req.params.customerId try { - await Tankerbooking.find({ customerId: customerId, orderStatus: ["rejected"]}) + await Tankerbooking.find({ orderStatus: ["rejected"]}) .limit(limit) .skip(startindex) .exec() diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index c76acc90..5f74480d 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -201,22 +201,33 @@ exports.getTanklevels = async (req, reply) => { try { const customerId = req.params.customerId; - const updated_data = await Tank.find({ customerId: customerId }); - - reply.send({ status_code: 200, data: updated_data}); + let sumSumpDrinkingWater = 0; + let sumOverheadDrinkingWater = 0; - return { message: 'success' }; -} + updated_data.forEach((tank) => { + if (tank.tankLocation === 'sump' && tank.typeOfWater === 'Drinking Water') { + sumSumpDrinkingWater += parseInt(tank.waterlevel); + } else if (tank.tankLocation === 'overhead' && tank.typeOfWater === 'Drinking Water') { + sumOverheadDrinkingWater += parseInt(tank.waterlevel); + } + }); - catch (err) { + reply.send({ + status_code: 200, + data: updated_data, + totalDrinkingWaterInSump: sumSumpDrinkingWater, + totalDrinkingWaterInOverhead: sumOverheadDrinkingWater + }); + + return { message: 'success' }; + } catch (err) { throw boom.boomify(err); } }; - exports.motorAction = async (req, reply) => { try { //let start_time,stop_time diff --git a/src/routes/supplierOrdersRoutes.js b/src/routes/supplierOrdersRoutes.js index 0300c2eb..b1f086dd 100644 --- a/src/routes/supplierOrdersRoutes.js +++ b/src/routes/supplierOrdersRoutes.js @@ -506,16 +506,16 @@ module.exports = function (fastify, opts, next) { tags: ["Supplier-Order"], description:"This is for Get All order cancelled", summary: "This is for Get All order cancelled", - params: { - required: ["customerId"], - type: "object", - properties: { - customerId: { - type: "string", - description: "customerId", - }, - }, - }, + // params: { + // required: ["customerId"], + // type: "object", + // properties: { + // customerId: { + // type: "string", + // description: "customerId", + // }, + // }, + // }, security: [ { diff --git a/src/routes/tankersRoute.js b/src/routes/tankersRoute.js index e9d8fbf2..47d7e9cf 100644 --- a/src/routes/tankersRoute.js +++ b/src/routes/tankersRoute.js @@ -31,30 +31,32 @@ module.exports = function (fastify, opts, next) { tankerName: { type: "string" }, phoneNumber: { type: "string"}, alternative_phoneNumber: { type: "string"}, - typeofwater: { - type: "array", - maxItems: 2500, - items: { - type: "object", - properties: { - typeofwater: { type: "string", default: null }, - }, - }, - }, + // typeofwater: { + // type: "array", + // maxItems: 2500, + // items: { + // type: "object", + // properties: { + // typeofwater: { type: "string", default: null }, + // }, + // }, + // }, - price: { - type: "array", - maxItems: 2500, - items: { - type: "object", - properties: { - price: { type: "string", default: null }, - }, - }, - }, + // price: { + // type: "array", + // maxItems: 2500, + // items: { + // type: "object", + // properties: { + // price: { type: "string", default: null }, + // }, + // }, + // }, + typeofwater: { type: "string"}, + price: { type: "string"}, capacity: { type: "string"}, // price: {type : "string"}, - // status: {type: "string"} + // status: {type: "string"} @@ -104,27 +106,29 @@ module.exports = function (fastify, opts, next) { tankerName: { type: "string" }, phoneNumber: { type: "string"}, alternative_phoneNumber: { type: "string"}, - typeofwater: { - type: "array", - maxItems: 2500, - items: { - type: "object", - properties: { - typeofwater: { type: "string", default: null }, - }, - }, - }, + // typeofwater: { + // type: "array", + // maxItems: 2500, + // items: { + // type: "object", + // properties: { + // typeofwater: { type: "string", default: null }, + // }, + // }, + // }, - price: { - type: "array", - maxItems: 2500, - items: { - type: "object", - properties: { - price: { type: "string", default: null }, - }, - }, - }, + // price: { + // type: "array", + // maxItems: 2500, + // items: { + // type: "object", + // properties: { + // price: { type: "string", default: null }, + // }, + // }, + // }, + typeofwater: { type: "string"}, + price: { type: "string"}, capacity: { type: "string"},