From b42cceb1dfb6e2a2ad74a722e470d2796a921e82 Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 14 May 2025 12:02:10 +0530 Subject: [PATCH 01/10] origin in cors --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index b2fd6a0f..d464523d 100644 --- a/src/index.js +++ b/src/index.js @@ -27,7 +27,7 @@ const fastify = require("fastify")({ // const Fastify = require("fastify"); fastify.register(cors, { - origin: 'http://localhost:3001', // Allow only your frontend URL + origin: 'http://armintaaqua.com:3000', // Allow only your frontend URL methods: ['GET', 'POST', 'PUT', 'DELETE'], // Allowed HTTP methods }); From ce14ecbb59062d6bf2f19c0b535fe786fd5328c7 Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 14 May 2025 12:57:33 +0530 Subject: [PATCH 02/10] changes --- src/models/store.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/models/store.js b/src/models/store.js index 57551f8f..6a1ca22a 100644 --- a/src/models/store.js +++ b/src/models/store.js @@ -605,7 +605,7 @@ const orderSchema = new mongoose.Schema({ master_connections: [ { master_name: { type: String, default: null }, - + hardwareId: { type: String, default: null }, slaves: { type: String, default: null }, location: { type: String, default: null }, googleLocation: { type: String, default: null }, From 1c80ecc477324a3b8d050bace57d720962f33abe Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 14 May 2025 14:22:30 +0530 Subject: [PATCH 03/10] changes --- src/controllers/storeController.js | 1 + src/models/store.js | 1 + 2 files changed, 2 insertions(+) diff --git a/src/controllers/storeController.js b/src/controllers/storeController.js index ee3483dd..ff07314f 100644 --- a/src/controllers/storeController.js +++ b/src/controllers/storeController.js @@ -2319,6 +2319,7 @@ exports.acceptQuotation = async (req, reply) => { status: "blocked", customerId, connected_to: masterHardwareId, + tankhardwareId: `tank-${j + 1}`, hardwareId: slave.hardwareId, tankName: tank.tankName || "", tankLocation: tank.tankLocation || "", diff --git a/src/models/store.js b/src/models/store.js index 6a1ca22a..d4823797 100644 --- a/src/models/store.js +++ b/src/models/store.js @@ -602,6 +602,7 @@ const orderSchema = new mongoose.Schema({ datetime: { type: String, default: null }, updated_at: { type: String, default: null }, assignedTeamMembers: [{ type: String }], + tankhardwareId: [{ type: String,default: null }], master_connections: [ { master_name: { type: String, default: null }, From a4d9abe7c3ae081aa6f6393b32e4bb2a32c21424 Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 14 May 2025 14:23:34 +0530 Subject: [PATCH 04/10] changes --- src/routes/storeRoute.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/storeRoute.js b/src/routes/storeRoute.js index 5038c582..4ddad3df 100644 --- a/src/routes/storeRoute.js +++ b/src/routes/storeRoute.js @@ -1220,7 +1220,7 @@ fastify.post('/api/updateSensorQC/:hardwareId', { tags: ['Store-Data'], summary: 'Update QC fields of a sensor', params: { - required: ['_ihardwareIdd'], + required: ['hardwareIdd'], type: 'object', properties: { hardwareId: { type: 'string', description: 'Sensor ID' }, From 712489a80ec22ed6978559ff56a785107d8ab88f Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 14 May 2025 14:25:12 +0530 Subject: [PATCH 05/10] changes --- src/routes/storeRoute.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/storeRoute.js b/src/routes/storeRoute.js index 4ddad3df..de166380 100644 --- a/src/routes/storeRoute.js +++ b/src/routes/storeRoute.js @@ -1220,7 +1220,7 @@ fastify.post('/api/updateSensorQC/:hardwareId', { tags: ['Store-Data'], summary: 'Update QC fields of a sensor', params: { - required: ['hardwareIdd'], + required: ['hardwareId'], type: 'object', properties: { hardwareId: { type: 'string', description: 'Sensor ID' }, From 06f3f00123b1d8dd5309256d6415b7b5bd50b5bc Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 14 May 2025 14:28:59 +0530 Subject: [PATCH 06/10] changes --- src/controllers/storeController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/storeController.js b/src/controllers/storeController.js index ff07314f..2c8a93a6 100644 --- a/src/controllers/storeController.js +++ b/src/controllers/storeController.js @@ -1324,7 +1324,7 @@ exports.updateSensorQC = async (req, reply) => { filteredUpdateData.qccheckdate = moment().format('DD-MMM-YYYY - HH:mm'); // Find the sensor by ID - const updatedSensor = await Insensors.findByIdAndUpdate( + const updatedSensor = await Insensors.findOneAndUpdate( hardwareId, filteredUpdateData, { new: true } From e9ff60cefccd70579e428941d1c8b640fd57f658 Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 14 May 2025 14:36:50 +0530 Subject: [PATCH 07/10] changes --- src/models/store.js | 3 +++ src/routes/storeRoute.js | 2 ++ 2 files changed, 5 insertions(+) diff --git a/src/models/store.js b/src/models/store.js index d4823797..b5a2291a 100644 --- a/src/models/store.js +++ b/src/models/store.js @@ -469,6 +469,9 @@ lora_last_disconnect_time : { type: String, default: null }, power_check: { result: String }, master_connecting_gsm: { result: String }, slave_connecting: { result: String }, + motor_start: { result: String }, + motor_stop: { result: String }, + motor_starting: { result: String, steps: [ diff --git a/src/routes/storeRoute.js b/src/routes/storeRoute.js index de166380..59881457 100644 --- a/src/routes/storeRoute.js +++ b/src/routes/storeRoute.js @@ -1243,6 +1243,8 @@ fastify.post('/api/updateSensorQC/:hardwareId', { power_check: { type: 'string' }, master_connecting_gsm: { type: 'string' }, slave_connecting: { type: 'string' }, + motor_start: { type: 'string' }, + motor_stop: { type: 'string' }, motor_starting: { type: 'object', properties: { From 644630e53a1c2a7fa689d532d4a2612f448fae7b Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 14 May 2025 14:47:00 +0530 Subject: [PATCH 08/10] chnages --- src/controllers/storeController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/storeController.js b/src/controllers/storeController.js index 2c8a93a6..470a5b7c 100644 --- a/src/controllers/storeController.js +++ b/src/controllers/storeController.js @@ -1317,7 +1317,7 @@ exports.updateSensorQC = async (req, reply) => { // Ensure qccheck is handled properly if (filteredUpdateData.qccheck) { const qccheckLower = filteredUpdateData.qccheck.toLowerCase(); - filteredUpdateData.status = qccheckLower === 'ok' ? 'available' : 'qcfailed'; + filteredUpdateData.status = qccheckLower === 'Pass' ? 'available' : 'qcfailed'; } // Update qccheckdate with the current date in "DD-MMM-YYYY - HH:MM" format From ec82d9281adddd379fdadb8dc21b3c2a0d4ffb38 Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 14 May 2025 14:57:25 +0530 Subject: [PATCH 09/10] changes in starta and stop --- src/controllers/tanksController.js | 27 +++++++++++++++++++++++ src/routes/tanksRoute.js | 35 ++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index 9daca387..a8b3a6fa 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -2880,7 +2880,34 @@ exports.motoractiontest = async (req, reply) => { } }; +exports.motoractiontestbeforeqc = async (req, reply) => { + try { + + + + + + + + + if (action === "start") { + await this.publishMotorStopStatus(motor_id, "2"); + } else if (action === "stop") { + await this.publishMotorStopStatus(motor_id, "1"); + } else { + return reply.status(400).send({ success: false, message: "Invalid action" }); + } + + return reply.send({ success: true, message: `Motor ${action} command sent.` }); + + + + } catch (error) { + console.error("Error fetching data:", error); + return reply.status(500).send({ success: false, message: "Internal Server Error" }); + } +}; const motorIntervals = {}; diff --git a/src/routes/tanksRoute.js b/src/routes/tanksRoute.js index 3f098f0b..78e0951a 100644 --- a/src/routes/tanksRoute.js +++ b/src/routes/tanksRoute.js @@ -415,6 +415,41 @@ module.exports = function (fastify, opts, next) { }); + + fastify.route({ + method: "PUT", + url: "/api/motoractiontestbeforeqc", + schema: { + tags: ["Install"], + summary: "This is for start and stop test before qc", + + + + body: { + type: "object", + // required: ['phone'], + properties: { + + motor_id:{type:"string"}, + action:{type:"string"}, + + }, + }, + security: [ + { + basicAuth: [], + }, + ], + }, + // preHandler: [ + // fastify.auth([fastify.operatorAuthenticate]), + // validationHandler.validatePhoneFormat, + // ], + //preHandler: fastify.auth([fastify.authenticate]), + handler: tanksController.motoractiontestbeforeqc, + }); + + // fastify.route({ // method: "PUT", // url: "/api/consumption/:customerId", From c4839608f35a9d0b22d90db71f615be72b5dbd44 Mon Sep 17 00:00:00 2001 From: Varun Date: Wed, 14 May 2025 15:02:09 +0530 Subject: [PATCH 10/10] changes --- src/controllers/tanksController.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/controllers/tanksController.js b/src/controllers/tanksController.js index a8b3a6fa..e0ca8921 100644 --- a/src/controllers/tanksController.js +++ b/src/controllers/tanksController.js @@ -2884,7 +2884,7 @@ exports.motoractiontestbeforeqc = async (req, reply) => { try { - + const { motor_id, action } = req.body;