changes in stores

master^2
Varun 10 months ago
parent f850849fab
commit 59c2550412

@ -1239,7 +1239,7 @@ exports.updateSensorQC = async (req, reply) => {
const { _id } = req.params;
let updateData = req.body;
const allowedFields = ["qccheck", "qcby", "comment"];
const allowedFields = ["qccheck", "qcby", "comment","status"];
// Filter only allowed fields
const filteredUpdateData = Object.keys(updateData)
@ -1269,6 +1269,29 @@ exports.updateSensorQC = async (req, reply) => {
}
};
exports.getSensorsByStatus = async (req, reply) => {
try {
const { storeId } = req.params;
const statuses = ["pending", "available", "rejected"];
let result = {};
for (const status of statuses) {
result[status] = await Insensors.find({ storeId, status });
}
return reply.code(200).send(result);
} catch (error) {
console.error("Error fetching sensors:", 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})

@ -270,6 +270,7 @@ const insensorsSchema = new mongoose.Schema({
quantity: { type: Number, default: 0 },
batchno: { type: String, default: null },
sensor_type: { type: String, enum: ['slaves', 'motorswitch', 'master'] }, // adding sensor_type field
status: { type: String, default: "pending" },
});

@ -1181,12 +1181,32 @@ fastify.post("/api/updateSensorQC/:_id", {
qccheck: { type: "string", description: "QC check status" },
qcby: { type: "string", description: "QC checked by" },
comment: { type: "string", description: "QC comment" },
status: { type: "string" },
},
},
},
handler: storeController.updateSensorQC,
});
fastify.get("/api/getSensorsByStatus/:storeId", {
schema: {
description: "Get list of sensors grouped by status for a given store",
tags: ["Store-Data"],
summary: "Retrieve sensors grouped by status",
params: {
type: "object",
required: ["storeId"],
properties: {
storeId: {
type: "string",
description: "Store ID",
},
},
},
},
handler: storeController.getSensorsByStatus,
});
fastify.get("/api/getbatchnumbers/:storeId/:type", {
schema: {

Loading…
Cancel
Save