diff --git a/src/controllers/installationController.js b/src/controllers/installationController.js index 8357711d..d191a390 100644 --- a/src/controllers/installationController.js +++ b/src/controllers/installationController.js @@ -603,7 +603,6 @@ exports.assignTeamMemberToQuotation = async (request, reply) => { // Step 2: Get GSM Time from first tank time if available const firstTankTime = latestRecord.tanks?.[0]?.time || new Date(latestRecord.date).toTimeString().split(' ')[0]; - const connected_gsm_time = firstTankTime; // Step 3: Update Insensor @@ -624,10 +623,23 @@ exports.assignTeamMemberToQuotation = async (request, reply) => { console.log("Updated connected_gsm_date/time:", connected_gsm_date, connected_gsm_time); } + // Step 4: Check tank connection status + const tanksWithStatus = latestRecord.tanks.map(tank => { + const height = parseFloat(tank.tankHeight || "0"); + const connectionStatus = height > 0 ? "GSM Connected" : "GSM Not Connected"; + return { + ...tank, + connectionStatus + }; + }); + return reply.send({ status_code: 200, message: "Success", - data: iotData + data: { + ...latestRecord, + tanks: tanksWithStatus + } }); } catch (err) { @@ -637,6 +649,7 @@ exports.assignTeamMemberToQuotation = async (request, reply) => { }; + exports.getByHardwareAndTankId = async (req, reply) => {