master^2
Bhaskar 7 months ago
parent 147a5ab2f7
commit 0e6be3f54b

@ -604,32 +604,36 @@ exports.assignTeamMemberToQuotation = async (request, reply) => {
const connected_gsm_time = now.toTimeString().split(' ')[0]; // hh:mm:ss const connected_gsm_time = now.toTimeString().split(' ')[0]; // hh:mm:ss
// Update insensor where connected_to = hardwareId // Update insensor where connected_to = hardwareId
await Insensors.findOneAndUpdate( const updateResult = await Insensors.findOneAndUpdate(
{ connected_to: hardwareId }, { connected_to: hardwareId },
{ {
connected_gsm_time, $set: {
connected_gsm_date connected_gsm_time,
connected_gsm_date
}
}, },
{ new: true } { new: true }
); );
// Optionally fetch updated insensor if you want to include it in response if (!updateResult) {
const sensor = await Insensors.findOne({ connected_to: hardwareId }); console.log("No insensor found with connected_to =", hardwareId);
} else {
console.log("Updated connected_gsm_date/time:", connected_gsm_date, connected_gsm_time);
}
return reply.send({ return reply.send({
status_code: 200, status_code: 200,
message: "Success", message: "Success",
data:iotData, data: iotData
}); });
} catch (err) { } catch (err) {
console.error("Error:", err); console.error("Error in getByHardwareId:", err);
return reply.status(500).send({ error: "Internal Server Error" }); return reply.status(500).send({ error: "Internal Server Error" });
} }
}; };
exports.getByHardwareAndTankId = async (req, reply) => { exports.getByHardwareAndTankId = async (req, reply) => {

Loading…
Cancel
Save