|
|
|
@ -1218,6 +1218,41 @@ exports.updateSensorById = async (req, reply) => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.updateSensorQC = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
const { _id } = req.params;
|
|
|
|
|
let updateData = req.body;
|
|
|
|
|
|
|
|
|
|
const allowedFields = ["qccheck", "qcby", "comment"];
|
|
|
|
|
|
|
|
|
|
// Filter only allowed fields
|
|
|
|
|
const filteredUpdateData = Object.keys(updateData)
|
|
|
|
|
.filter((key) => allowedFields.includes(key))
|
|
|
|
|
.reduce((obj, key) => {
|
|
|
|
|
obj[key] = updateData[key];
|
|
|
|
|
return obj;
|
|
|
|
|
}, {});
|
|
|
|
|
|
|
|
|
|
// Update qccheckdate with the current date in "DD-MMM-YYYY - HH:MM" format
|
|
|
|
|
filteredUpdateData.qccheckdate = moment().format("DD-MMM-YYYY - HH:mm");
|
|
|
|
|
|
|
|
|
|
const updatedSensor = await Insensors.findByIdAndUpdate(
|
|
|
|
|
_id,
|
|
|
|
|
filteredUpdateData,
|
|
|
|
|
{ new: true }
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
if (!updatedSensor) {
|
|
|
|
|
return reply.code(404).send({ message: "Sensor not found" });
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return reply.code(200).send(updatedSensor);
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.error("Error updating QC fields:", error);
|
|
|
|
|
return reply.code(500).send({ message: "Internal Server Error" });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
exports.getpumpswitchqc = async (req, reply) => {
|
|
|
|
|
try {
|
|
|
|
|
await MotorSwitchSensor.find({storeId: req.params.storeId,motorId:req.body.motorId})
|
|
|
|
|