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